﻿using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.Text;

namespace SharpSoft.Net.P2P
{
    public interface IPeer : IDisposable
    {
        void Bind(EndPoint endPoint); 
        void Connect(EndPoint endPoint);
        void Disconnect(bool reuse);
        /// <summary>
        /// 发送数据
        /// </summary> 
        int Send(byte[] buffer, int offset, int size, SocketFlags flags);
        /// <summary>
        /// 接收从远端发来的消息
        /// </summary>
        /// <returns></returns>
        int Receive(byte[] buffer, int offset, int size, SocketFlags flags);
        /// <summary>
        /// 在断开连接后触发
        /// </summary>
        event EventHandler Disconnected;
    }
}
